var t,
  a = require("../../@babel/runtime/helpers/defineProperty"),
  i = require("../../res/www.a9a.cn.js"),
  e = getApp();
Page({
  data: { nTitle: "学堂" },
  onLoad: function (t) {
    var a = this;
    this.setData({ fid: t.id }),
      wx.setNavigationBarTitle({ title: a.data.nTitle }),
      e.get_config("_ZEAI").then(function (t) {
        a.setData({ color: e._ZEAI.color, rgbcolor: i.c16_rgb(e._ZEAI.color) });
      }),
      e.get_navigationBarTopHeight(a),
      e.get_openid().then(function (t) {
        a.init();
      });
  },
  init: function () {
    var a = this;
    i.ifint(a.data.fid) ||
      wx.showModal({
        content: "fid跑路了",
        confirmColor: a.data.color,
        confirmText: "朕知道了",
        showCancel: !1,
        success: function (t) {
          wx.navigateBack();
        },
      }),
      wx.showLoading({ title: "玩命加载中...", mask: !0 }),
      (t = wx.getStorageSync("COOK_U")),
      e.ajax({
        url: "article.php",
        data: { submitok: "article_detail", openid: t.openid, fid: a.data.fid },
        success: function (t) {
          if (1 == t.flag) {
            var e = i.escape2Html(t.D.content);
            a.setData({
              D: t.D,
              nTitle: t.D.nTitle,
              content: e,
              tjU: t.tjU,
              KEFU: t.KEFU,
              AGREE: t.AGREE,
              TJ: t.TJ,
              BBS: t.BBS,
              ios_ifpay: t.ios_ifpay,
            });
          } else wx.showToast({ title: t.msg, icon: "none", mask: !0 });
          wx.hideLoading();
        },
      });
  },
  agree_payFn: function () {
    var t = this;
    e.chklogin().then(function (a) {
      a
        ? t.setData({ agree_pay_show: !0 })
        : wx.navigateTo({ url: "../login/login" });
    });
  },
  getPhoneNumber: function (t) {
    e.getPhoneNumber({ e: t, url: "../reg/reg" });
  },
  agree_pay_numFn: function (a) {
    this.setData({ agree_pay_show: !1 });
    var n = this,
      o = a.currentTarget.dataset.money;
    e.chklogin().then(function (a) {
      a
        ? 1 != n.data.ios_ifpay.flag
          ? wx.getSystemInfo({
              success: function (a) {
                "ios" == a.platform
                  ? wx.showModal({
                      title: "温馨提示",
                      content: n.data.ios_ifpay.tips,
                      confirmColor: n.data.color,
                      cancelText: "返回",
                      confirmText: "联系服务人员",
                      success: function (t) {
                        t.confirm
                          ? wx.redirectTo({ url: "../my/hongniang" })
                          : t.cancel && wx.navigateBack();
                      },
                    })
                  : e.pay({
                      data: {
                        submitok: "article_detail_agree",
                        openid: t.openid,
                        fid: n.data.fid,
                        money: o,
                      },
                      success: function () {
                        wx.showModal({
                          content: "支付成功，非常感谢您的支持！",
                          confirmColor: n.data.color,
                          confirmText: "返回",
                          showCancel: !1,
                          success: function (t) {
                            n.init();
                          },
                        });
                      },
                      fail: function (t) {
                        (t.this = n), (t.url = "no"), i.sorry(t);
                      },
                    });
              },
            })
          : e.pay({
              data: {
                submitok: "article_detail_agree",
                openid: t.openid,
                fid: n.data.fid,
                money: o,
              },
              success: function () {
                wx.showModal({
                  content: "支付成功，非常感谢您的支持！",
                  confirmColor: n.data.color,
                  confirmText: "返回",
                  showCancel: !1,
                  success: function (t) {
                    n.init();
                  },
                });
              },
              fail: function (t) {
                (t.this = n), (t.url = "no"), i.sorry(t);
              },
            })
        : wx.navigateTo({ url: "../login/login" });
    });
  },
  agreeFn: function (n) {
    var o = this,
      s = n.currentTarget.dataset.idx,
      c = n.currentTarget.dataset.id,
      r = o.data.BBS[s].class;
    i.indexOf(r, "ed") ||
      ((t = wx.getStorageSync("COOK_U")),
      e.ajax({
        url: "article.php",
        data: {
          submitok: "bbs_agree",
          id: c,
          fid: o.data.fid,
          openid: t.openid,
        },
        success: function (t) {
          var e;
          1 == t.flag
            ? o.setData(
                (a((e = {}), "BBS[" + s + "].agreefly", "block"),
                a(e, "BBS[" + s + "].agree", parseInt(o.data.BBS[s].agree) + 1),
                a(e, "BBS[" + s + "].class", "ed"),
                e)
              )
            : ((t.this = o), (t.url = "no"), i.sorry(t));
        },
      }));
  },
  bbs_showFn: function () {
    wx.pageScrollTo({ scrollTop: 999999, duration: 300 });
  },
  bbs_addFn: function () {
    var t = this;
    e.chklogin().then(function (a) {
      a ? t.setData({ div_bbs: !0 }) : wx.navigateTo({ url: "../login/login" });
    });
  },
  div_bbs_submitFn: function (a) {
    var n = this,
      o = a.detail.value;
    e.empty(o.content)
      ? wx.showToast({ title: "请输入评论内容", icon: "none", mask: !0 })
      : wx.showModal({
          title: "",
          content:
            "确定提交么？\r\n以下情形话题将被删除或封号：\r\n《请勿留下任何形式联系方法》\r\n《请勿发表涉黄涉政言论》\r\n《不得辱骂或攻击他人》",
          confirmColor: n.data.color,
          cancelText: "取消",
          confirmText: "确定",
          success: function (a) {
            a.confirm &&
              (wx.showLoading({ title: "正在保存", mask: !0 }),
              e.ajax({
                url: "article.php",
                data: {
                  submitok: "bbs_add",
                  openid: t.openid,
                  fid: n.data.fid,
                  content: o.content,
                },
                success: function (t) {
                  wx.hideLoading(),
                    1 == t.flag
                      ? wx.showModal({
                          content: t.msg,
                          confirmColor: n.data.color,
                          confirmText: "朕知道了",
                          showCancel: !1,
                          success: function (t) {
                            n.setData({ div_bbs: !1 }), n.init();
                          },
                        })
                      : ((t.this = n), (t.url = "no"), i.sorry(t));
                },
              }));
          },
        });
  },
  back: function () {
    this.setData({ div_login: !1 });
  },
  onPageScroll: function (t) {
    t.scrollTop > 100
      ? this.setData({ backtop_flag: !0 })
      : this.setData({ backtop_flag: !1 });
  },
  backtopFn: function (t) {
    wx.pageScrollTo({ scrollTop: 0, duration: 300 });
  },
  kefuFn: function (t) {
    1 == this.data.D.ifps
      ? tt.navigateTo({ url: "../about/about" })
      : this.setData({ kefushow: !0 });
  },
  kefu_closeFn: function () {
    this.setData({ kefushow: !1, agree_pay_show: !1, div_bbs: !1 });
  },
  onShareAppMessage: function () {
    return {
      imageUrl: this.data.D.path_b,
      title: this.data.D.wxshareT,
      path: "/pages/article/article_detail?id=" + this.data.fid,
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.data.D.path_b,
      title: this.data.D.wxshareT,
      query: "id=" + this.data.fid,
      path: "/pages/article/article_detail",
    };
  },
  ifagreeFn: function (t) {
    1 == t.detail.value
      ? this.setData({ ifagree: !0 })
      : this.setData({ ifagree: !1 });
  },
  ifagree_passFn: function () {
    wx.showToast({
      title: "请先点击同意《用户协议》和《隐私条款》",
      icon: "none",
      mask: !0,
      duration: 3e3,
    });
  },
});
